package com.example.ioc1.controller;

import com.example.ioc1.model.DbType;
import com.example.ioc1.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("yml")
public class ReadymlController {
    @Value("${mykey}")
    private String key;

    @Value("${server.port}")
    private Integer port;

    @Value("${mykey.key1}")
    private String key1;

    @Value("${string.str1}")
    private String str1;

    @Value("${string.str2}")
    private String str2;

    @Value("${string.str3}")
    private String str3;

    @Autowired
    private Student student;

    @Autowired
    private DbType dbType;

    @RequestMapping("/readyml")
    public String readYml() {
        return "从yml中获取配置文件" + key;
    }

    @RequestMapping("/readyml2")
    public String readYml2() {
        return "从yml中获取配置文件" + port;
    }

    @RequestMapping("/readyml3")
    public String readYml3() {
        return "从yml中获取配置文件" + key1;
    }

    @RequestMapping("/readyml4")
    public String readYml4() {
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
        return "从yml中获取配置文件";
    }

    @RequestMapping("/readyml5")
    public String readYml5() {
        return "从yml中获取配置文件" + student.toString();
    }

    @RequestMapping("/readyml6")
    public String readYml6() {
        System.out.println(dbType.getName().size());
        return "从yml中获取配置文件" + dbType;
    }
}
